import { createRouter, createWebHistory, Router, RouteRecordRaw } from 'vue-router'
import Home from '@/views/Home/Home.vue'
import Detail from '@/views/Detail/Detail.vue'
import Hot from '@/views/Hot/Hot.vue'
import Rank from '@/views/Rank/Rank.vue'
import Update from '@/views/Update/Update.vue'
import Category from '@/views/Category/Category.vue'
import Search from '@/views/Search/Search.vue'
import History from '@/views/History/History.vue'
import Read from '@/views/Read/Read.vue'
import Error from '@/views/Error/Error.vue'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/history',
    name: 'History',
    component: History
  },
  {
    path: '/search',
    name: 'Search',
    component: Search
  },
  {
    path: '/detail/:book_id',
    name: 'Detail',
    component: Detail
  },
  {
    path: '/read/:book_id/:chapter_id',
    name: 'Read',
    component: Read
  },
  {
    path: '/hot',
    name: 'Hot',
    component: Hot
  },
  {
    path: '/rank',
    name: 'Rank',
    component: Rank
  },
  {
    path: '/update',
    name: 'Update',
    component: Update
  },
  {
    path: '/category',
    name: 'Category',
    component: Category
  },
  {
    path: '/error',
    name: 'Error',
    component: Error
  },
  { path: '/:pathMatch(.*)*', redirect: '/error' }
]

const router: Router = createRouter({
  history: createWebHistory(),
  routes
})

export default router
